<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <h1>{{message}}</h1>
  <cpn></cpn>
  <cpn></cpn>
  <cpn></cpn>

</div>

<template id="cpn">
  <div>
    <h1>当前计数：{{counter}}</h1>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
  </div>
</template>

<script src="../js/vue.js"></script>
<script>

  const obj = {
    counter: 0
  }

  Vue.component('cpn',{
    template: `#cpn`,
    data() {
      return obj;
    },
    methods: {
      increment() {
        return this.counter++
      },
      decrement() {
        return this.counter--
      }
    }
  })
  //let(变量)和const(常量)
  const app = new Vue({
    el: '#app',
    data: {
      message: '中国牛蛙！'
    }
  })
</script>
</body>
</html>